package com.rt.gptnext.common.utils.json;

import cn.hutool.core.util.ArrayUtil;

/**
 * 敏感字段转为星号
 *
 * @author gaoyiyang
 */
public class FieldStarFilter implements com.alibaba.fastjson2.filter.ValueFilter {

    public static final FieldStarFilter INSTANCE = new FieldStarFilter();

    /** 需要加密字段 */
    private static final String[] STAR_FIELD = {"password", "pass"};

    @Override
    public Object apply(Object object, String name, Object value) {
        if (ArrayUtil.contains(STAR_FIELD, name)) {
            return "******";
        }
        return value;
    }
}
